//WY3 小易的升级之路
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int a = in.nextInt();
            long[] arr = new long[n];
            long c = a;
            for(int i=0;i<n;i++){
                arr[i]=in.nextLong();
            }
            for(int i=0;i<n;i++){
                if(c>=arr[i]){
                    c+=arr[i];
                }else{
                    c+=gcd(arr[i],c);
                }
            }
            System.out.println(c);
        }
    }
    public static long gcd(long a,long b){
        long temp=a;
        while(temp!=0){
            a=b;
            b=temp;
            temp=a%b;
        }
        return b;
    }
}


//JZ47 礼物的最大价值
public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param grid int整型二维数组
     * @return int整型
     */
    public int maxValue (int[][] grid) {
        int n = grid.length;
        int m = grid[0].length;
        int[][] dp = new int[n+1][m+1];

        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                dp[i][j]=Math.max(dp[i-1][j]+grid[i-1][j-1],dp[i][j-1]+grid[i-1][j-1]);
            }
        }
        return dp[n][m];
    }
}




//对称之美
class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();

        while (t-- > 0) {
            int n = in.nextInt();
            String[] s = new String[n];
            List<Set<Character>> list = new ArrayList<>();

            // 读取字符串并初始化 HashSet
            for (int i = 0; i < n; i++) {
                s[i] = in.next();
                list.add(new HashSet<>());
                for (char c : s[i].toCharArray()) {
                    list.get(i).add(c);
                }
            }

            // 检查是否能构成回文
            boolean canFormPalindrome = true;
            for (int i = 0; i < n / 2; i++) {
                Set<Character> set1 = list.get(i);
                Set<Character> set2 = list.get(n - 1 - i);
                boolean foundCommon = false;

                for (char c : set1) {
                    if (set2.contains(c)) {
                        foundCommon = true;
                        break;
                    }
                }

                if (!foundCommon) {
                    canFormPalindrome = false;
                    break;
                }
            }

            System.out.println(canFormPalindrome ? "Yes" : "No");
        }
        in.close();
    }
}
